package com.yunhe.option.domain.data;

import com.yunhe.common.util.StringUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 季节电价对象
 * @desc 季节电价对象定义
 * @author liuronglei
 */
@ApiModel(value = "SeasonPrice", description = "季节电价对象")
@NodeEntity
public class SeasonPrice implements Serializable {
    @ApiModelProperty(value = "季节电价id")
    @GraphId
    private Long id;
    @ApiModelProperty(value = "季节名称name")
    private String name;
    @ApiModelProperty(value = "季节名称")
    private String title;
    @ApiModelProperty(value = "适用月份")
    private String runMonth;
    @ApiModelProperty(value = "电价费率")
//    private List<PriceRate> priceRates;
    private List<Long> priceRates;
    @ApiModelProperty(value = "季节电价详情")
    @Relationship(type = "HAS_DETAIL")
    private List<SeasonPriceDetail> seasonPriceDetails;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getRunMonth() {
        return runMonth;
    }

    public void setRunMonth(String runMonth) {
        String[] split = runMonth.split(",");
        List<Integer> list = new ArrayList<>();
        for (String s : split) {
            if (StringUtil.isNumber(s)) {
                list.add(Integer.parseInt(s));
            }
        }
        Collections.sort(list);
        StringBuffer buffer = new StringBuffer();
        for (Integer integer : list) {
            buffer.append(integer).append(",");
        }
        String string = buffer.toString();
        this.runMonth = string.substring(0, string.length() - 1);
    }

    public List<Long> getPriceRates() {
        return priceRates;
    }

    public void setPriceRates(List<Long> priceRates) {
        this.priceRates = priceRates;
    }

    public List<SeasonPriceDetail> getSeasonPriceDetails() {
        return seasonPriceDetails;
    }

    public void setSeasonPriceDetails(List<SeasonPriceDetail> seasonPriceDetails) {
        this.seasonPriceDetails = seasonPriceDetails;
    }
}
